#include <stdio.h>
#include "CRC.h"



unsigned char testBuf1[12] = {0x88, 0xff, 0x20, 0x03, 0x24, 0x12, 0x12, 0x25, 0x00, 0x00, 0x00, 0x00};
unsigned int crcCode1;
unsigned short crcCode2;
unsigned char crcCode3;



int main(void)
{
	//CRC32TableInit();
	crcCode1 = CRC32_Table(testBuf1, 8);
	printf("crcCode1 = 0x%x\n", crcCode1);
	*((unsigned int*)&testBuf1[8]) = crcCode1;
	crcCode1 = CRC32_Table(testBuf1, 12);
	printf("crcCode1 = 0x%x\n", crcCode1);
	for(unsigned int i = 0; i < 12; i++)
	{
		printf("0x%x ", testBuf1[i]);
	}

	printf("\n");
	printf("\n-------------------------------------------------------------------------------------\n");

	//CRC16ModbusTableInit();
	crcCode2 = CRC16_Modbus_Table(testBuf1, 8);
	printf("crcCode2 = 0x%x\n", crcCode2);
	*((unsigned short*)&testBuf1[8]) = crcCode2;
	crcCode2 = CRC16_Modbus_Table(testBuf1, 10);
	printf("crcCode2 = 0x%x\n", crcCode2);
	for(unsigned int i = 0; i < 10; i++)
	{
		printf("0x%x ", testBuf1[i]);
	}

	printf("\n");
	printf("\n-------------------------------------------------------------------------------------\n");


	//CRC8MAXIMTableInit();
	crcCode3 = CRC8_MAXIM_Table(testBuf1, 8);
	printf("crcCode3 = 0x%x\n", crcCode3);
	*((unsigned char*)&testBuf1[8]) = crcCode3;
	crcCode3 = CRC8_MAXIM_Table(testBuf1, 9);
	printf("crcCode3 = 0x%x\n", crcCode3);
	for(unsigned int i = 0; i < 9; i++)
	{
		printf("0x%x ", testBuf1[i]);
	}

	printf("\n");
	printf("\n-------------------------------------------------------------------------------------\n");


	//CRC8TableInit();
	crcCode3 = CRC8_Table(testBuf1, 8);
	printf("crcCode3 = 0x%x\n", crcCode3);
	*((unsigned char*)&testBuf1[8]) = crcCode3;
	crcCode3 = CRC8_Table(testBuf1, 9);
	printf("crcCode3 = 0x%x\n", crcCode3);
	for(unsigned int i = 0; i < 9; i++)
	{
		printf("0x%x ", testBuf1[i]);
	}

	printf("\n");
	printf("\n-------------------------------------------------------------------------------------\n");

	return 0;
}
